﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modulos/ModuloVenta/VistaControl/MasterPageVenta.master" AutoEventWireup="true" CodeFile="RegistroVenta.aspx.cs" Inherits="Modulos_ModuloVenta_VistaControl_Default" %>

<%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

   
    
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>"
        SelectCommand="SELECT * FROM [RECTIFICACION]" 
        OldValuesParameterFormatString="original_{0}" 
        ConflictDetection="CompareAllValues" 
        DeleteCommand="DELETE FROM [RECTIFICACION] WHERE [RCT_COD] = @original_RCT_COD AND [RCT_DATE] = @original_RCT_DATE AND [RCT_TOTAL] = @original_RCT_TOTAL" 
        InsertCommand="INSERT INTO [RECTIFICACION] ([RCT_DATE], [RCT_TOTAL]) VALUES (@RCT_DATE, @RCT_TOTAL)" 
        
        UpdateCommand="UPDATE [RECTIFICACION] SET [RCT_DATE] = @RCT_DATE, [RCT_TOTAL] = @RCT_TOTAL WHERE [RCT_COD] = @original_RCT_COD AND [RCT_DATE] = @original_RCT_DATE AND [RCT_TOTAL] = @original_RCT_TOTAL">
        <DeleteParameters>
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_RCT_TOTAL" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="RCT_TOTAL" Type="Int32" />
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_RCT_TOTAL" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="RCT_TOTAL" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>

   
    
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>" 
        DeleteCommand="DELETE FROM [VENTA] WHERE [VNT_COD] = @original_VNT_COD AND [USR_RUT] = @original_USR_RUT AND [VNT_DATE] = @original_VNT_DATE AND (([VNT_TOTAL] = @original_VNT_TOTAL) OR ([VNT_TOTAL] IS NULL AND @original_VNT_TOTAL IS NULL)) AND [VNT_VLC] = @original_VNT_VLC" 
        InsertCommand="INSERT INTO [VENTA] ([USR_RUT], [VNT_DATE], [VNT_TOTAL], [VNT_VLC]) VALUES (@USR_RUT, @VNT_DATE, @VNT_TOTAL, @VNT_VLC)" 
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [VENTA]" 
        
        UpdateCommand="UPDATE [VENTA] SET [USR_RUT] = @USR_RUT, [VNT_DATE] = @VNT_DATE, [VNT_TOTAL] = @VNT_TOTAL, [VNT_VLC] = @VNT_VLC WHERE [VNT_COD] = @original_VNT_COD AND [USR_RUT] = @original_USR_RUT AND [VNT_DATE] = @original_VNT_DATE AND (([VNT_TOTAL] = @original_VNT_TOTAL) OR ([VNT_TOTAL] IS NULL AND @original_VNT_TOTAL IS NULL)) AND [VNT_VLC] = @original_VNT_VLC">
        <DeleteParameters>
            <asp:Parameter Name="original_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_USR_RUT" Type="Int32" />
            <asp:Parameter Name="original_VNT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_VNT_TOTAL" Type="Int32" />
            <asp:Parameter Name="original_VNT_VLC" Type="Boolean" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="USR_RUT" Type="Int32" />
            <asp:Parameter Name="VNT_DATE" Type="DateTime" />
            <asp:Parameter Name="VNT_TOTAL" Type="Int32" />
            <asp:Parameter Name="VNT_VLC" Type="Boolean" />
            <asp:Parameter Name="original_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_USR_RUT" Type="Int32" />
            <asp:Parameter Name="original_VNT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_VNT_TOTAL" Type="Int32" />
            <asp:Parameter Name="original_VNT_VLC" Type="Boolean" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="USR_RUT" Type="Int32" />
            <asp:Parameter Name="VNT_DATE" Type="DateTime" />
            <asp:Parameter Name="VNT_TOTAL" Type="Int32" />
            <asp:Parameter Name="VNT_VLC" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>" 
        DeleteCommand="DELETE FROM [RECTIFICACION] WHERE [RCT_COD] = @original_RCT_COD AND [RCT_DATE] = @original_RCT_DATE AND [RCT_TOTAL] = @original_RCT_TOTAL" 
        InsertCommand="INSERT INTO [RECTIFICACION] ([RCT_DATE], [RCT_TOTAL]) VALUES (@RCT_DATE, @RCT_TOTAL)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM [RECTIFICACION]" 
        
        UpdateCommand="UPDATE [RECTIFICACION] SET [RCT_DATE] = @RCT_DATE, [RCT_TOTAL] = @RCT_TOTAL WHERE [RCT_COD] = @original_RCT_COD AND [RCT_DATE] = @original_RCT_DATE AND [RCT_TOTAL] = @original_RCT_TOTAL">
        <DeleteParameters>
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_RCT_TOTAL" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="RCT_TOTAL" Type="Int32" />
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="original_RCT_TOTAL" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="RCT_DATE" Type="DateTime" />
            <asp:Parameter Name="RCT_TOTAL" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>

   
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>" 
        
        SelectCommand="SELECT * FROM [LISTA_RECTIFICACIONES]" 
        ConflictDetection="CompareAllValues" 
        DeleteCommand="DELETE FROM [LISTA_RECTIFICACIONES] WHERE [LT_RCT_COD] = @original_LT_RCT_COD AND [RCT_COD] = @original_RCT_COD AND [VNT_COD] = @original_VNT_COD AND (([LT_RCT_CMT] = @original_LT_RCT_CMT) OR ([LT_RCT_CMT] IS NULL AND @original_LT_RCT_CMT IS NULL))" 
        InsertCommand="INSERT INTO [LISTA_RECTIFICACIONES] ([RCT_COD], [VNT_COD], [LT_RCT_CMT]) VALUES (@RCT_COD, @VNT_COD, @LT_RCT_CMT)" 
        OldValuesParameterFormatString="original_{0}" 
        
        UpdateCommand="UPDATE [LISTA_RECTIFICACIONES] SET [RCT_COD] = @RCT_COD, [VNT_COD] = @VNT_COD, [LT_RCT_CMT] = @LT_RCT_CMT WHERE [LT_RCT_COD] = @original_LT_RCT_COD AND [RCT_COD] = @original_RCT_COD AND [VNT_COD] = @original_VNT_COD AND (([LT_RCT_CMT] = @original_LT_RCT_CMT) OR ([LT_RCT_CMT] IS NULL AND @original_LT_RCT_CMT IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_LT_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_LT_RCT_CMT" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="RCT_COD" Type="Decimal" />
            <asp:Parameter Name="VNT_COD" Type="Decimal" />
            <asp:Parameter Name="LT_RCT_CMT" Type="String" />
            <asp:Parameter Name="original_LT_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_RCT_COD" Type="Decimal" />
            <asp:Parameter Name="original_VNT_COD" Type="Decimal" />
            <asp:Parameter Name="original_LT_RCT_CMT" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="RCT_COD" Type="Decimal" />
            <asp:Parameter Name="VNT_COD" Type="Decimal" />
            <asp:Parameter Name="LT_RCT_CMT" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    
    <h2> Registro de Rectificaciones </h2>
    <p>Aquí podrá Rectificar las ventas con errores. 
    </p>
    
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="RCT_COD" 
        DataSourceID="SqlDataSource2" ondatabinding="Page_Load">
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="RCT_COD" HeaderText="RCT_COD" InsertVisible="False" 
                ReadOnly="True" SortExpression="RCT_COD" />
            <asp:BoundField DataField="RCT_DATE" HeaderText="RCT_DATE" 
                SortExpression="RCT_DATE" />
            <asp:BoundField DataField="RCT_TOTAL" HeaderText="RCT_TOTAL" 
                SortExpression="RCT_TOTAL" />
        </Columns>
    </asp:GridView>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="RCT_COD" 
        DataSourceID="SqlDataSource2">
        <EditItemTemplate>
            RCT_COD:
            <asp:Label ID="RCT_CODLabel1" runat="server" Text='<%# Eval("RCT_COD") %>' />
            <br />
            RCT_DATE:
            <asp:TextBox ID="RCT_DATETextBox" runat="server" 
                Text='<%# Bind("RCT_DATE") %>' />
            <br />
            RCT_TOTAL:
            <asp:TextBox ID="RCT_TOTALTextBox" runat="server" 
                Text='<%# Bind("RCT_TOTAL") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Actualizar" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
        </EditItemTemplate>
        <InsertItemTemplate>
            &nbsp;<table style="width: 100%">
                <tr>
                    <td>
                        Fecha</td>
                    <td>
                        :</td>
                    <td>
                        <asp:TextBox ID="RCT_DATETextBox" runat="server" 
                            Text='<%# Bind("RCT_DATE") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        Total</td>
                    <td>
                        :</td>
                    <td>
                        <asp:TextBox ID="RCT_TOTALTextBox" runat="server" style="margin-bottom: 0px" 
                            Text='<%# Bind("RCT_TOTAL") %>' />
                    </td>
                </tr>
            </table>
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insertar" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
        </InsertItemTemplate>
        <EmptyDataTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Rectificación" />
        </EmptyDataTemplate>
        <ItemTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Venta" />
            <br />
        </ItemTemplate>
    </asp:FormView>
    <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="LT_RCT_COD" 
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="LT_RCT_COD" HeaderText="LT_RCT_COD" 
                InsertVisible="False" ReadOnly="True" SortExpression="LT_RCT_COD" />
            <asp:BoundField DataField="RCT_COD" HeaderText="RCT_COD" 
                SortExpression="RCT_COD" />
            <asp:BoundField DataField="VNT_COD" HeaderText="VNT_COD" 
                SortExpression="VNT_COD" />
            <asp:BoundField DataField="LT_RCT_CMT" HeaderText="LT_RCT_CMT" 
                SortExpression="LT_RCT_CMT" />
        </Columns>
    </asp:GridView>
    <asp:FormView ID="FormView2" runat="server" DataKeyNames="LT_RCT_COD" 
        DataSourceID="SqlDataSource1">
        <EditItemTemplate>
            LT_RCT_COD:
            <asp:Label ID="LT_RCT_CODLabel1" runat="server" 
                Text='<%# Eval("LT_RCT_COD") %>' />
            <br />
            RCT_COD:
            <asp:TextBox ID="RCT_CODTextBox" runat="server" Text='<%# Bind("RCT_COD") %>' />
            <br />
            VNT_COD:
            <asp:TextBox ID="VNT_CODTextBox" runat="server" Text='<%# Bind("VNT_COD") %>' />
            <br />
            LT_RCT_CMT:
            <asp:TextBox ID="LT_RCT_CMTTextBox" runat="server" 
                Text='<%# Bind("LT_RCT_CMT") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Actualizar" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
        </EditItemTemplate>
        <InsertItemTemplate>
            &nbsp;<table style="width: 100%">
                <tr>
                    <td style="width: 69px">
                        Rectificación</td>
                    <td style="width: 5px">
                        :</td>
                    <td>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="SqlDataSource3" DataTextField="RCT_COD" DataValueField="RCT_COD" 
                            SelectedValue='<%# Bind("RCT_COD") %>'>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td style="width: 69px">
                        Venta</td>
                    <td style="width: 5px">
                        :</td>
                    <td>
                        <asp:DropDownList ID="DropDownList2" runat="server" 
                            DataSourceID="SqlDataSource4" DataTextField="VNT_COD" DataValueField="VNT_COD" 
                            SelectedValue='<%# Bind("VNT_COD") %>'>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td style="width: 69px">
                        Comentario</td>
                    <td style="width: 5px">
                        :</td>
                    <td>
                        <asp:TextBox ID="LT_RCT_CMTTextBox" runat="server" 
                            Text='<%# Bind("LT_RCT_CMT") %>' />
                    </td>
                </tr>
            </table>
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insertar" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
        </InsertItemTemplate>
        <ItemTemplate>
            &nbsp;&nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo" />
        </ItemTemplate>
        <EmptyDataTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo" />
        </EmptyDataTemplate>
    </asp:FormView>
    <br />  
    
</asp:Content>
